<!-- 名片审核 -->
<template>
  <div class='card_audit'>
    <Tabs v-model="curState" type="card" :animated="false" @on-click="onChangeTab">
      <TabPane label="待审核" name="0"></TabPane>
      <TabPane label="已通过" name="1"></TabPane>
      <TabPane label="已驳回" name="2"></TabPane>
    </Tabs>
    <dt-grid ref="table" page :onFetch='onFetch' />
    <process-modal ref="process" />
  </div>
</template>

<script>
  import Column from './opt/columns'
  import auditMgr from '@/biz/flowApproval/processAudit.js'
  import processModal from '@/components/biz/audit/process-modal.vue'
  export default {
    components: { processModal },
    data() {
      return {
        curState: '0',
        oldState: '0',
      };
    },
    methods: {
      onChangeTab(val) {
        if (val == this.oldState) return false
        this.oldState = val
        this.init(true)
      },
      onFetch(data) {
        return auditMgr.list({
          ...data,
          auditType: 8,
          buttonType: this.curState
        }).then(res => {
          res && res.list.forEach(item => {
            item = Object.assign(item, item.auditData)
          })
          return res
        })
      },
      init(flag = false) {
        this.$refs.table.init(this, new Column(this))
        this.$refs.table.fetch(flag)
      },
      auditFun(data) {
        console.log(data)
        this.$router.push({
          name: 'auditDetail',
          query: { businessId: data.businessId, auditId: data.auditId },
        })
      },
      processFun(data) {
        this.$refs.process.show({
          businessId: data.businessId,
          auditType: 8
        })
      }
    },
    mounted() {
      console.log(22323)

      this.init()
    }
  }
</script>
<style lang='scss' scoped>
  .card_audit {
    padding: 15px;
  }
</style>